100 REM **********************************************************************
110 REM FILE NAME  - SAVEFILE.BAS
120 REM
130 REM WRITTEN BY - GARY PEEK
140 REM              3201 HIGHGATE
150 REM              ST. CHARLES, MO.  63301
160 REM              314 946-5272
170 REM
180 REM LAST UPDATE - 3/30/87
190 REM
200 REM DESCRIPTION - SAVE DATA COMING IN A SERIAL PORT TO A DISK FILE.
210 REM               NOTE: ENTER BASIC LIKE THIS - "GWBASIC SAVEFILE /C:32767"
220 REM               THIS INCREASES THE SIZE OF THE COMMUNICATIONS BUFFER.
230 REM               LONG FILES AT HIGH BAUD RATES MAY OVERFLOW BUFFER ANYWAY.
240 REM               DATA OTHER THAN ASCII MAY CAUSE SCREEN TO MISBEHAVE,
250 REM               BUT PROGRAM SHOULD CONTINUE WORKING.
260 REM
270 REM PLEASE NOTE - PERMISSION IS GRANTED TO COPY THIS PROGRAM ONLY IF
280 REM               COPIED IN ITS ENTIRETY INCLUDING THIS HEADING.
290 REM
300 REM **********************************************************************
310 REM
320 CLS:LOCATE ,,1:PRINT "PROGRAM TO SAVE DATA COMING IN COM PORT"
330 PRINT:PRINT
340 INPUT "Save to what FILE NAME";N$
350 IF N$="" THEN END
360 PRINT:PRINT:PRINT "OPENING FILE - please wait ....";
370 CLOSE:OPEN "COM2:300,N,8,1,CS,DS,CD" AS #1       :REM BAUD RATE AND PORT
380 OPEN N$ FOR OUTPUT AS #2
390 CLS:PRINT "saving file ";N$
400 PRINT:PRINT "WAITING FOR DATA..."
410 PRINT:PRINT "When data stops being printed hit RETURN to close file.":PRINT
420 ON ERROR GOTO 510
430 IF NOT EOF(1) THEN GOTO 460
440 IN$=INKEY$:IF IN$="" THEN GOTO 430
450 GOTO 520
460 A$=INPUT$(1,1)
470 IF A$=CHR$(9) THEN A$=SPACE$(8-(LEN(B$) MOD 8))
480 IF A$=CHR$(10) THEN GOTO 500
490 PRINT A$;
500 PRINT #2,A$;:GOTO 430
510 RESUME
520 PRINT:PRINT:PRINT "CLOSING FILE ...";
530 CLOSE:GOTO 320
